<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@include('layouts.common.head')
<!-- Fonts -->
    <!-- Styles -->
    <link href="{{asset('static/css/home/base.css') }}?v=<?php echo time() ?>" rel="stylesheet">
    <link href="{{asset('static/css/common.css')}}?v=<?php echo time() ?>" rel="stylesheet" type="text/css">
    <link href="{{asset('static/css/jobs.css')}}?v=<?php echo time() ?>" rel="stylesheet" type="text/css">
</head>
<body>
<div id="app" style="min-height: 600px">
    @include('layouts.nav')
    @include('home.other_top_nav')
    <div class="new-search-box">
        <div class="ns-main">
            <div class="main-sty">
                <div class="sty-cell J_sli_jc" data-type="full">全文
                    <div class="sty-aow"></div>
                </div>
                <div class="clear"></div>
            </div>
            <div class="main-sip">
                <div class="ip-group">
                    <form id="ajax_search_location"
                          action=""
                          method="get">
                        <div class="ip-box">
                            <input type="text" name="key" id="autoKeyInput" data-original=""
                                   value="{{\Illuminate\Support\Facades\Input::get('key')}}"
                                   placeholder="请输入职位名称或公司名称"/>
                        </div>
                        <div class="for-border" style="background: #fff"></div>
                        <div class="ip-city" data-toggle="funCityModal" data-title="请选择地区" data-multiple="false"
                             data-maximum="0"
                             data-width="630">
                        </div>
                        <div class="ip-btn"><input type="submit" class="sobut J_hoverbut" value="找工作"/></div>
                    </form>
                </div>

                <div class="clear"></div>
            </div>
        </div>
    </div>
    <div class="so_condition J_so_condition">


        {{--<div class="lefttit">地标地段</div>--}}
        {{--<div class="rs">--}}
        {{----}}
        {{--<div onclick="javascript:location.href='{:P(array(\'citycategory\'=>$city[\'parent\'][\'citycategory\']))}'"--}}
        {{--class="li">全杭州--}}
        {{--</div>--}}

        {{--<div onclick="javascript:location.href='{:P(array(\'citycategory\'=>$district[\'citycategory\']))}'"--}}
        {{--class="li">下城区--}}
        {{--</div>--}}
        {{--<div class="clear"></div>--}}
        {{--</div>--}}
        {{--<div class="clear"></div>--}}

        <div class="lefttit">职位薪资</div>
        <div class="rs">
            <div class="li search-param @if(isSet($params['wage']) && $params['wage'] == 0) select @endif"
                 data-list="wage" data-code="0">不限
            </div>
            @foreach($category['_wage'] as $key=> $item)
                <div class="li search-param @if(isSet($params['wage']) && $params['wage'] == $key) select @endif"
                     data-list="wage" data-code="{{$key}}">
                    {{$item}}
                </div>
            @endforeach
            <div class="clear"></div>
        </div>
        <div class="clear"></div>


        <div class="lefttit">更多筛选</div>
        <div class="rs">
            <div class="bli J_dropdown">
                <span class="txt" title="">所属行业</span>
                <div class="dropdowbox_searchtrade J_dropdown_menu">
                    <div class="dropdow_inner_searchtrade">
                        <ul class="nav_box">
                            @foreach($category['_trade'] as $key=>$item)
                                <li class="search-param" data-list="trade" data-code="{{$key}}"
                                    title="{{$item}}">{{$item}}</li>
                            @endforeach
                            <div class="clear"></div>
                        </ul>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
            <div class="bli J_dropdown">
                <span>@if(isSet($params['scale'])) {{$category['_scale'][$params['scale']]}}@else 企业规模 @endif</span>
                <div class="dropdowbox_noa J_dropdown_menu">
                    <div class="dropdow_inner_noa">
                        <ul class="nav_box">
                            @foreach($category['_scale'] as $key=>$item)
                                <li class="search-param" data-list="scale" data-code="{{$key}}">{{$item}}
                                </li>
                            @endforeach
                        </ul>
                    </div>
                </div>
                <div class="clear"></div>
            </div>

            <div class="bli J_dropdown">
                <span>
                    @if(isSet($params['time']))
                        @if($params['time'] ==3)
                            3天内
                        @elseif($params['time'] ==7)
                            7天内
                        @elseif($params['time'] ==15)
                            15天内
                        @elseif($params['time'] ==30)
                            30天内
                        @endif
                    @else
                        更新时间
                    @endif
                </span>
                <div class="dropdowbox_noa J_dropdown_menu">
                    <div class="dropdow_inner_noa">
                        <ul class="nav_box">
                            <li class="search-param" data-list="time" data-code="3">
                                3天内
                            </li>
                            <li class="search-param" data-list="time" data-code="7">
                                7天内
                            </li>
                            <li class="search-param" data-list="time" data-code="15">
                                15天内
                            </li>
                            <li class="search-param" data-list="time" data-code="30">
                                30天内
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>

        <!--已选条件，当没有条件的时候不显示下面的DIV -->
        @if(isSet($params['key']) || isSet($params['trade']) || isSet($params['scale']) || isSet($params['time']) || isSet($params['c']))
            <div class="selected J_selected" style="display: block">
                <div class="stit">已选条件</div>
                <div class="sc">
                    @if(isSet($params['key']))
                        <div class="slist" data-name="key">
                            <span>关键字：</span> {{$params['key']}}
                        </div>
                    @endif
                    @if(isSet($params['trade']) && isSet($category['_trade'][$params['trade']]))
                        <div class="slist" data-name="trade">
                            <span>职位分类：</span>
                            {{$category['_trade'][$params['trade']]}}
                        </div>
                    @endif
                    @if(isSet($params['c']))
                        <div class="slist" data-name="c">
                            <span>职位：</span>
                            {{$categories['_trade'][$params['c']]}}
                        </div>
                    @endif
                    @if(isSet($params['scale']) && isSet($category['_scale'][$params['scale']]))
                        <div class="slist" data-name="scale">
                            <span>企业规模：</span>
                            {{$category['_scale'][$params['scale']]}}
                        </div>
                    @endif
                    @if(isSet($params['time']))
                        <div class="slist" data-name="time">
                            <span>更新时间：</span>
                            {{$params['time']}}天之内
                        </div>
                    @endif
                    <div class="clear"></div>
                </div>

                <div class="sr">
                    <div class="empty" onclick="window.location.href='{{url("job")}}'">清空</div>
                </div>
                <div class="clear"></div>
            </div>
        @endif

    </div>

    <div class="plist">
        <div class="pl" style="min-height: 500px">
            <div class="toptitle">
                <div class="ltype">
                    <div class="typeli">所有职位
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="ts">
                    <div class="l1">
                    </div>
                    <div class="l2">
                    </div>
                    <div class="l2">
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="sort">
                    <div class="sl1">排序方式：</div>
                    <a class="sl2 search-param @if(isSet($params['sort']) && $params['sort'] == 'x') select @endif"
                       data-list="sort" data-code="x" href="javascript:;">相关度</a>
                    <a class="sl2 search-param @if(isSet($params['sort']) && $params['sort'] == 'z') select @endif"
                       data-list="sort" data-code="z" href="javascript:;">综合排序</a>
                    <a class="sl2 search-param @if(isSet($params['sort']) && $params['sort'] == 'g') select @endif"
                       data-list="sort" data-code="g" href="javascript:;">更新时间</a>
                    <div class="clear"></div>
                </div>
            </div>
            <!--列表 -->
            @if($jobs->first())
                <div class="listb J_allListBox">
                    @foreach($jobs as $item)
                        <div class="J_jobsList yli" data-jid="">
                            <div class="td1">

                            </div>
                            <div class="td2 link_blue link_visited has-alw">
                                <div class="td-j-name">
                                    <a href="{{url('job/info',[$item->id])}}" target="_blank"
                                       title="">{{$item->jobs_name}}</a>
                                </div>
                                <div class="td-j-img">
                                    {{--&nbsp;<img src="static/images/emergency.png">--}}
                                </div>
                                <div class="clear"></div>
                            </div>
                            <div class="td3 link_gray6">
                                <a class="line_substring" href="javascript:;">{{$item->company_cn}}</a>

                                {{--<img src="{:attach('auth.png','re ource')}" title="认证企业">--}}
                                <div class="clear"></div>
                            </div>

                            <div class="td4">@if($item->negotiable == 1)面议@else{{$item->min_wage}}-{{$item->max_wage}}
                                元/月@endif</div>
                            <div class="td5">
                                {{date('Y-m-d',$item->refresh_time)}}
                            </div>
                            <div class="td6">

                            </div>
                            <div class="clear"></div>

                            <div class="detail">
                                <div class="ltx">
                                    <div class="txt font_gray6">
                                        地点：{{$item->district_cn}}<span>|</span>人数：{{$item->amount}}人
                                    </div>
                                    @if(!empty($item->tag_cn))
                                        <?php $tags = explode('+', $item->tag_cn) ?>

                                        <div class="dlabs">
                                            @foreach($tags as $tag)
                                                <div class="dl">{{$tag}}</div>
                                            @endforeach
                                            <div class="clear"></div>
                                        </div>
                                    @endif
                                </div>
                                <div class="rbtn">
                                    {{--TODO 转移到model 判断是否是我已经报过的--}}
                                    {{--<div class="deliver J_applyForJob has-favor" data-batch="false" data-url="">--}}
                                    {{--已投递--}}
                                    {{--</div>--}}

                                    <div class="deliver J_applyForJobAllowance" data-id="{{$item->id}}"
                                         data-batch="false"
                                         onclick="window.location.href='{{url("job/info",[$item->id])}}'">
                                        查看工作
                                    </div>


                                    {{--<div class="favorites J_collectForJob has-favor" data-batch="false"--}}
                                    {{--data-url="{:U('AjaxPersonal/jobs_favorites')}">--}}
                                    {{--已收藏--}}
                                    {{--</div>--}}

                                    {{--<div class="favorites J_collectForJob" data-batch="false"--}}
                                    {{--data-url="{:U('AjaxPersonal/jobs_favorites')}">--}}

                                    {{--收藏--}}

                                    {{--</div>--}}
                                    <div class="map-area">杭州</div>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                    @endforeach
                    <div class="qspage" style="text-align: center">{{$jobs->links()}}</div>
                    <!--投递按钮 -->

                    @else
                        <div class="list_empty_group">
                            <div class="list_empty">
                                <div class="list_empty_left"></div>
                                <div class="list_empty_right">
                                    <div class="sorry_box">对不起，没有找到符合您条件的职位！</div>
                                    <div class="stips_box">放宽您的查找条件也许有更多合适您的职位哦~</div>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                </div>
            @endif
            <div class="clear"></div>

        </div>
    </div>
</div>
<div class="clear"></div>

<script type="text/javascript" src="{{asset('static/js/jquery.autocomplete.js')}}"></script>
<script type="text/javascript" src="{{asset('static/js/jquery.dropdown.js')}}"></script>
<script type="text/javascript">

    let url = window.location.search;

    function changeURLArg(url, arg, arg_val) {
        let pattern = arg + '=([^&]*)';
        let replaceText = arg + '=' + arg_val;
        if (url.match(pattern)) {
            let tmp = '/(' + arg + '=)([^&]*)/gi';
            tmp = url.replace(eval(tmp), replaceText);
            return tmp;
        } else {
            if (url.match('[\?]')) {
                return url + '&' + replaceText;
            } else {
                return url + '?' + replaceText;
            }
        }
    }

    $('.search-param').click(function () {
        let arg = $(this).data('list');
        let arg_val = $(this).data('code');

        url = changeURLArg(url, arg, arg_val);
        url = funcUrlDel('page',url);
        window.location.href = url;
    });

    function funcUrlDel(paramKey,url = window.location.href) {
        var urlParam = url.substr(1);   //页面参数
        var beforeUrl = url.substr(0, url.indexOf("?"));   //页面主地址（参数之前地址）
        var nextUrl = "";

        var arr = new Array();
        if (urlParam != "") {
            var urlParamArr = urlParam.split("&"); //将参数按照&符分成数组
            for (var i = 0; i < urlParamArr.length; i++) {
                var paramArr = urlParamArr[i].split("="); //将参数键，值拆开
                //如果键雨要删除的不一致，则加入到参数中
                if (paramArr[0] != paramKey) {
                    arr.push(urlParamArr[i]);
                }
            }
        }
        if (arr.length > 0) {
            nextUrl = "?" + arr.join("&");
        }
        url = beforeUrl + nextUrl;
        return url;
    }

    $('.slist').click(function () {
        var name = $(this).data('name');
        url = funcUrlDel('page',url);
        window.location.href = funcUrlDel(name,url);
    })
    // 投递简历


</script>

@include('layouts.register')
@include('layouts.common.foot')
</body>
</html>
